package cn.itsource.org.domain;

import cn.itsource.basic.domain.BaseTreeNode;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.persistence.*;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

/**
 * 部门实体类
 */
@Table(name = "t_department") //tkmybatis实体类指向的数据库表名
@Data  //生成get set toString
@ApiModel(value="部门对象", description="部门对象实体类")
public class Department extends BaseTreeNode<Department> {

    //编号
    @ApiModelProperty(value="部门编号")
    @NotBlank(message = "部门编号不能为空")
    private String sn;
    //名称
    @ApiModelProperty(value="部门名称")
    @Size(min = 1,max = 6,message = "名称必须在1-6位之间")
    private String name;
    //状态 0 正常 1禁用
    private Integer state;
    //部门经理id
    @Column(name = "manager_id")
    private Long managerId;
    @Column(name = "parent_id")
    //对应的父部门id
    private Long parentId;
    //先不管
    @Column(name = "dir_path")
    private String dirPath;

    //部门经理
    @Transient
    private Employee manager;
    //父级部门
    @Transient
    private Department parent;
    //上级部门结构数据
    @Transient
    private Long[] parentIds;
}
